package com.txf.simple.ui.activity;

import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;

import com.txf.simple.R;
import com.txf.simple.test.TestPermissionsActivity;
import com.txf.simple.test.testtv.TestTVActivity;
import com.txf.simple.test.testtv.TestTVMainActivity;

public class MainActivity extends AbsBaseActivity implements View.OnClickListener {
    @Override
    protected View buildContentView() {
        return LayoutInflater.from(getContext()).inflate(R.layout.activity_main,null);
    }
    @Override
    protected void initViews() {
        findViewById(R.id.test1).setOnClickListener(this);
        findViewById(R.id.test2).setOnClickListener(this);
        findViewById(R.id.test3).setOnClickListener(this);
        findViewById(R.id.test4).setOnClickListener(this);
        findViewById(R.id.test5).setOnClickListener(this);
        findViewById(R.id.test6).setOnClickListener(this);
        findViewById(R.id.test7).setOnClickListener(this);
        findViewById(R.id.test8).setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.test1:
                startActivity(new Intent(getContext(), TestPermissionsActivity.class));
            case R.id.test2:
                startActivity(new Intent(getContext(), TestTVMainActivity.class));
                break;
            case R.id.test3:
                startActivity(new Intent(getContext(), TestTVActivity.class));
                break;
            case R.id.test4:
                openUrl("http://www.baidu.com/");
                break;
            case R.id.test5:
                startActivity(new Intent(getContext(), ViewPagerActivity.class));
                break;
            case R.id.test6:
                startActivity(new Intent(getContext(), RxJavaActivity.class));
                break;
            case R.id.test7:
                startActivity(new Intent(getContext(), ADActivity.class));
                break;
            case R.id.test8:
                startActivity(new Intent(getContext(), PlayActivity.class));
                break;
        }
    }
    /**
     * 用自带浏览器打开url
     * */
    private void openUrl(String commonBean) {
        Intent intent = new Intent();
        intent.setAction("android.intent.action.VIEW");
        Uri content_url = Uri.parse(commonBean);
        intent.setData(content_url);
        startActivity(intent);
    }
}
